Library Packages

library(tidyverse)
## -- Attaching packages --------------------- tidyverse 1.2.1 --
## v ggplot2 3.1.0       v purrr   0.3.0  
## v tibble  2.0.1       v dplyr   0.8.0.1
## v tidyr   0.8.2       v stringr 1.4.0  
## v readr   1.3.1       v forcats 0.4.0
## -- Conflicts ------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

Data

duke_ncaa_forcast <-
  read_csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/historical-ncaa-forecasts/historical-538-ncaa-tournament-model-results.csv", 
    col_types = cols(year = col_date(format = "%Y"), favorite_win_flag = col_logical())) %>% 
  filter(favorite == "Duke", round < 3)

duke_ncaa_forcast
## # A tibble: 4 x 6
##   year       round favorite underdog favorite_probability favorite_win_flag
##   <date>     <dbl> <chr>    <chr>                   <dbl> <lgl>            
## 1 2012-01-01     2 Duke     Lehigh                  0.896 FALSE            
## 2 2014-01-01     2 Duke     Mercer                  0.929 FALSE            
## 3 2013-01-01     2 Duke     Albany                  0.946 TRUE             
## 4 2011-01-01     2 Duke     Hampton                 0.995 TRUE

ggplot2

duke_2ndround_win_probability <- 
ggplot(duke_ncaa_forcast, aes(x = year, y = favorite_probability)) +
  geom_point(aes(color = favorite_win_flag, 
                 shape = favorite_win_flag), size = 4) +
  geom_line() 

duke_2ndround_win_probability

Plotly via ggplotly

ggplotly(duke_2ndround_win_probability)